<template>
    <div id="MapList">
      <header class="header">
        <div class="title">
          <img src="../../assets/images/01_11.png" alt="" class="img_zuo" @click="back" />
          <div>任务总结</div>
        </div>
      </header>
      <div class="main">

        <van-list v-model="loading" :finished="finished" @load="onLoad">

          <div class="box_list" v-for="(obj,i) of list" @click="openXq(obj)">
            <img class="img_logo5" src="../../assets/images/rwls.png" />
            <div class="center">
              <div style="width: 70%;">
                <div class="small_title">{{obj.commitContent}}</div>
                <div class="introduce">
                  <div class="intro_name">
                    <img src="../../assets/images/people.png" />
                    <div>{{obj.username}}</div>
                  </div>
                </div>
              </div>
              <div class="data">{{getDateFormat(obj.commitDate,'MM-DD')}}</div>
            </div>
          </div>

        </van-list>

      </div>
    </div>
</template>
<script>
import { Dialog } from 'vant';
import utils from "../../assets/js/utils.js"
export default {
    name: "list_rwzj",
    data(){
        return{
          list:[],
          loading: false,
          finished: true,
          refreshing: false,
          page:1,
          pageSize:50,
          rwjbDwType: 0,
          userId:null,
          id:null
        }
    },
    methods:{
      getDateFormat(any_date,formatdate){//格式化日期
        return utils.dateFormat(any_date,formatdate);
      },
      onLoad() {
        var _this = this;
        if (_this.refreshing) {
          _this.list = [];
          _this.refreshing = false;
          _this.page = 1;
        }

        /*try{
          plus.nativeUI.showWaiting("正在加载...");
        }catch(e){
          console.log(e.message);
        }*/
        var params = {
          userId:_this.userId,
          taskSpecialId: _this.id,
          isPostOrGet:_this.rwjbDwType,
          page: _this.page,
          pageSize: _this.pageSize
        };
        /*params = {
          userId:2932,
          taskSpecialId: 375,
          isPostOrGet:1,
          page: _this.page,
          pageSize: _this.pageSize
        };*/
        _this.axios.get(_this.$global_msg.Url.host + "/taskAssign/selectBanliList",{params}).then(function (data) {
          console.log('data',data);
          if(data&&data.data){
            if(data.data.code==200){
              _this.list = _this.list.concat(data.data.rows);
              if(data.data.total||data.data.total===0){
                if(_this.list.length>=data.data.total){
                  _this.finished = true;
                }else{
                  _this.page++;
                }
              }else{
                _this.finished = true;
              }
            }else{
              _this.$toast(data.data.msg);
              _this.finished = true;
            }
          }else{
            _this.$toast('查询失败');
            _this.finished = true;
          }
          _this.loading = false;
          _this.$forceUpdate();
          try{
            plus.nativeUI.closeWaiting();
          }catch(e){
            console.log(e.message);
          }
        }).catch(error => {
          _this.$terminal._error(error);
        });
      },
      onRefresh() {
        // 清空列表数据
        this.finished = false;

        // 重新加载数据
        // 将 loading 设置为 true，表示处于加载状态
        this.loading = true;
        this.onLoad();
      },
      back(){
        //this.$router.push(this.xqda_params.path);
        this.$router.back()
      },
      openXq(obj){//打开详情查看
        console.log(obj);
        localStorage.setItem("rwzjxq_id",obj.id);
        localStorage.setItem("list_scrollTop",$('.main').scrollTop());
        this.$router.push("/rwzjxq");
      },
      plusReady: function () {

      },
    },
    created(){
      this.title = localStorage.getItem('Title')
      this.name = localStorage.getItem('name')
    },
    beforeCreate() {
      document.addEventListener("plusready", this.plusReady, false);
    },
    beforeRouteLeave(to, from, next) {
        Dialog.close();
        next();
    },
    //进入该页面时，用之前保存的滚动位置赋值
    beforeRouteEnter (to, from, next) {
        next(vm => {
          var list_scrollTop = localStorage.getItem("list_scrollTop");
          if(list_scrollTop||list_scrollTop===0){
            $('.main').animate({scrollTop: list_scrollTop}, 0);
          }else{
            vm.userId = localStorage.getItem('userId');
            vm.rwjbDwType = localStorage.getItem('rwjbDwType');
            vm.id = localStorage.getItem('rwjb_taskSpecialId');
            vm.list = [];
            vm.refreshing = false;
            vm.page = 1;
            vm.onRefresh();
          }
          localStorage.removeItem("list_scrollTop");
        })
    },
    mounted() {

    },
}
</script>
<style scoped>
  #MapList{
    width: 100%;
    height: 100%;
    z-index: 40;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
  }
  .header {
    height: 1.8519rem;
    background: #007aff;
    padding-top: 0.8333rem;
    box-sizing: border-box;
    width: 100%;
    font-size: 0.388888rem;
    position: relative;
  }

  .title {
    padding: 0 0.3704rem;
    display: flex;
    align-items: center;
    color: #fff;
  }

  .title>div {
    width: 100%;
    font-size: 0.4444rem;
    text-align: center;
  }

  .img_zuo {
    width: 0.2593rem;
    height: 0.463rem;
  }
  .btn-search{
    position: absolute;
    right: 1.388888rem;
    bottom: 0.388888rem;
    width: 0.629629rem;
    height: 0.629629rem;
  }
  .btn-add{
    position: absolute;
    right: 0.37037rem;
    font-size: 1.111111rem !important;
  }

  .main {
    /*padding-top: 1.8519rem;*/
    /* height: 100vh; */
    box-sizing: border-box;
    background-color: rgb(247, 247, 249);
    /*padding-bottom: 3.796314814814815rem; */
    /* padding-top: 10.0008px; */
    flex: 1;
    overflow: scroll;
  }


  /* 列表 */
  .box_list {
    display: flex;
    align-items: center;
    height: 1.3889rem;
    width: 100%;
    background-color: #FFFFFF;
    border-bottom: 1Px solid #DDDDDD;
  }
  .img_logo5 {
    width: 0.6667rem;
    height: 0.7407rem;
    margin: 0 0.37037rem;
  }
  .center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .small_title {
    width: 5.6481rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .introduce {
    display: flex;
    color: #8E8E8E;
    font-size: 0.3148rem;
    align-items: center;
    margin-top: 0.0926rem;
  }
  .intro_name {
    display: flex;
    align-items: center;
    /* margin-left: 0.5rem; */
  }
  .intro_name img {
    width: 0.2963rem;
    margin-right: 0.1852rem;
  }

  .intro_name div {
    font-size: 0.2963rem;
  }
  .data {
    /*color: #8E8E8E;*/
    margin-right: 0.37037rem;
  }
</style>
